

package io.renren.modules.sys.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.renren.modules.sys.entity.SysRoleEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 角色管理
 *
 * @author Mark sunlightcs@gmail.com
 */
@Mapper
public interface SysRoleDao extends BaseMapper<SysRoleEntity> {

    /**
     * 查询用户创建的角色ID列表
     */
    List<Long> queryRoleIdList(Long createUserId);

    /**
     * 根据用户id，查询用户的角色
     */
    @Select("SELECT t2.* FROM sys_user_role t1 " +
            "LEFT JOIN sys_role t2 ON t1.role_id = t2.role_id " +
            "WHERE t1.user_id = #{userId}")
    List<SysRoleEntity> queryListByUserId(@Param("userId") Long userId);
}
